#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int a[N], b[N], num, root[N];
struct Node {
  int cnt;
  int ch[2];
} tr[N << 5];
#define lc(p) tr[p].ch[0]
#define rc(p) tr[p].ch[1]
#define cnt(p) tr[p].cnt
int newnode(int p) {
  static int tot = 0;
  ++tot;
  cnt(tot) = cnt(p);
  lc(tot) = lc(p);
  rc(tot) = rc(p);
  return tot;
}
void update(int x, int& p, int l, int r) {
  p = newnode(p);
  cnt(p)++;
  if (l == r) return;
  int mid = (l + r) >> 1;
  if (x <= mid)
    update(x, lc(p), l, mid);
  else
    update(x, rc(p), mid + 1, r);
}
int query(int k, int p1, int p2, int l, int r) {
  if (l == r) return l;
  int mid = (l + r) >> 1;
  int x = cnt(lc(p2)) - cnt(lc(p1));
  if (x >= k)
    return query(k, lc(p1), lc(p2), l, mid);
  else
    return query(k - x, rc(p1), rc(p2), mid + 1, r);
}
void build() {
  rep(i, 1, n) {
    root[i] = root[i - 1];
    update(a[i], root[i], 1, num);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) cin >> a[i];
  // discrete
  rep(i, 1, n) b[i] = a[i];
  sort(b + 1, b + n + 1);
  num = unique(b + 1, b + n + 1) - b - 1;
  rep(i, 1, n) a[i] = lower_bound(b + 1, b + num + 1, a[i]) - b;
  build();
  while (m--) {
    int l, r, k;
    cin >> l >> r >> k;
    int pos = query(k, root[l - 1], root[r], 1, num);
    cout << b[pos] << endl;
  }
  return 0;
}